package com.tsingteng.cosfun.ui.costar.publish;

import com.tsingteng.cosfun.bean.CommBean;
import com.tsingteng.cosfun.bean.HomeBean;
import com.tsingteng.cosfun.bean.OpusBean;
import com.tsingteng.cosfun.bean.UserBean;
import com.tsingteng.cosfun.bean.VideoMusicBean;
import com.tsingteng.cosfun.bean.VideoSignBean;
import com.tsingteng.cosfun.callback.RxObserver;
import com.tsingteng.cosfun.mvp.presenter.BasePresenter;

import java.util.List;

/**
 * 描述 :
 * 创建人: 肖利.
 * 时间:2018/8/6
 * qq(872179966)
 */

public class VideoPublishPresenter extends BasePresenter<VideoContract.IVideoView> implements VideoContract.IVideoPresenter {

    private VideoModel videoModel;
    private VideoContract.IVideoView mView;

    public VideoPublishPresenter() {
        videoModel = new VideoModel();
    }

    @Override
    public void getSignTureData(int type) {
        mView= getView();
        if (mView==null)return;
        RxObserver<VideoSignBean> mVideoPublish = new RxObserver<VideoSignBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
                mView.showFail(errorMsg);
            }

            @Override
            protected void onSuccess(VideoSignBean videoSignBean) {
                mView.UploadVideo(videoSignBean);
            }
        };
        videoModel.getSignaTure(String.valueOf(type),mVideoPublish);
        addDisposable(mVideoPublish);
    }

    @Override
    public void getPublishVideo(String paragraph_id, String json) {
        mView = getView();
        if (mView==null)return;
        RxObserver<CommBean> rxObserver = new RxObserver<CommBean>(this) {
            @Override
            protected void onFaile(int errorCode, String errorMsg) {
                mView.showFail(errorMsg);
            }

            @Override
            protected void onSuccess(CommBean userBean) {
                mView.showPublishVideo(userBean.getVideo());
            }
        };
        videoModel.getPublishVideo(paragraph_id,json,rxObserver);
        addDisposable(rxObserver);
    }


}
